﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.Entity;
using COM.OA.BLL;
using System.Collections.Generic;

public partial class qs_rizhi_piyuedelete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            users loginuser = Session["loginuser"] as users;
            int uidd = loginuser.u_id;
            string where5 = "op_u_id='{0}'";
            where5 = string.Format(where5, uidd);
            IList<operate> listop = operateBLL.Select(where5);
            operate op = listop[0];
            int quanxian = op.op_pop_id;

            if (loginuser == null)
            {
                this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
                return;
            }
            else if (quanxian < 1)
            {
                this.Response.Write(string.Format(GetRedirect.WINALERT, "您不是经理没有批阅条件"));
                this.Response.Write(string.Format(GetRedirect.REDIRECT, "rizhipiyue.aspx"));
            }
            else
            {
                string id = this.Request.QueryString["w_id"];
                int wid = Int32.Parse(id);
                worklog wl = worklogBLL.Select(wid);
                //发送人ＩＤ
                int uid = wl.w_u_id;
                users us = usersBLL.Select(uid);
                //批阅人ＩＤ
                int pid = wl.w_readerid;

                users up = usersBLL.Select(pid);

                this.txtUname.Text = us.u_username;
                this.txtBiaoTi.Text = wl.w_title;
                this.txtNeiRong.Text = wl.w_content;


                this.txtPeiId.Text = up.u_username;
            }


        }
    }
    protected void btXiuGai_Click(object sender, EventArgs e)
    {
        string pname = this.txtPeiId.Text;
        string where = "u_username='{0}'";
        //根据姓名查部门ＩＤ
        where = string.Format(where, pname);
        IList<users> list = usersBLL.Select(where);
        users us = list[0];
        int pid = us.u_id;


        string peineirong = this.ftbXiuNR.Text;
        DateTime ptime = DateTime.Now;
        string wwid = this.Request.QueryString["w_id"];
        int w_id = Int32.Parse(wwid);
        worklog wl = worklogBLL.Select(w_id);



        //重新封装
        worklog wll = new worklog();

        wll.w_id = wl.w_id;
        wll.w_title = wl.w_title;
        wll.w_clicks = wl.w_clicks;
        wll.w_content = wl.w_content;
        wll.w_sendtime = wl.w_sendtime;
        //讨论后再定
        wll.w_state = wl.w_state;
        wll.w_u_id = wl.w_u_id;
        wll.w_readerid = pid;
        wll.w_readcontent = peineirong;
        wll.w_readtime = ptime;

        worklogBLL.Update(wll);
        this.Response.Redirect("rizhipiyue.aspx");
    }
   
}
